package ru.firststeps.speedtest;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class DataDBHelper extends SQLiteOpenHelper implements BaseColumns {
    public static final String TABLE_NAME = "measure";
    public static final String SPEED = "connection_speed";
    public static final String LATITUDE = "latitude";
    public static final String LONGITUDE = "longitude";
    public static final String CONNECTION_TYPE = "connection_type";
    public static final String OPERATOR = "operator";

    public DataDBHelper(Context context) {
        super(context, DataProvider.DB_DATA, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + TABLE_NAME
                + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, " + CONNECTION_TYPE + " STRING," + OPERATOR + " STRING," + SPEED + " STRING,"
                + LATITUDE + " DOUBLE," + LONGITUDE + " DOUBLE);");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
    }

}
